angular.module('dataServiceApp',[])
.service('commonDataService',['$http','$q',function($http,$q){
    return{
        //获取设备号
        getSbh:function(){
            var deferred = $q.defer();
            $http({
                url:'device/getAll', 
                method:'get'              
            }).success(function(response){
                if (response.status==1001) {
                    deferred.resolve(response.body);
                };
            });
            return deferred.promise;
        },
        getByArgid:function(argid){
            var deferred=$q.defer();
            $http({
                url:'device/getByargid/'+argid,
            }).success(function(response){
                if(response.status==1001){
                    deferred.resolve(response.body);
                }
            });
            return deferred.promise;
        },
        getLastData:function(data){
            var deferred=$q.defer();
            $http({
                url:'args/getLastRecord',
                method:'post',
                data:data
            }).success(function(response){
                if(response.status==1001)
                deferred.resolve(response.body);
            });
            return deferred.promise;
        }
    };
}]);
